package test.examation;

import java.util.*;

public class Solution {
    static int count;
    public  static void CalulateMethodCount (int n) {


        if(n==0) count++;
        for(int i=1;i<=n;i++){
            CalulateMethodCount(n-i);
        }

    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        System.out.println(handler(s));


    }
    public static String handler(String string){
        if(string==null||string.length()==0) return null;
        String[] s = string.split(" ");
        Map<String,Integer> map=new LinkedHashMap<>();//0代表正常输出，1 undo代表撤销前一个字符串，-1代表redo 重做前一个字符串

        for(int i=0;i<s.length;i++){
            map.put(s[i],0);
        }
        int pre = 0;
        for(int i=0;i<s.length;i++){
            if(map.get(s[i]).equals("undo")){
                map.put(s[i-1],1);
                pre=i-1;
            }
            if(map.get(s[i]).equals("redo")){
                map.put(s[pre],-1);
            }
        }
        Set<String> keys = map.keySet();
        StringBuilder sb=new StringBuilder();
        for (String key : keys) {
            if(key.equals("redo")||key.equals("undo")) continue;
            if(map.get(key)==0||map.get(key)==-1) sb.append(key+" ");
        }
        return sb.toString().trim();
    }
}